﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Filmek
{
    public partial class LoginForm : Form
    {
        private MyReader reader ;
        private int jog;
		private int felhID;
		private String felhNev;

        public LoginForm()
        {
            InitializeComponent();
        }

        private void OkButton_Click(object sender, EventArgs e)
        {
            bool err= true;
            reader = new MyReader(ref err);
            string nev = nevTextBox.Text.ToString();
            string jelszo = jelszoTextBox.Text.ToString();
             jog = reader.Login(nev,jelszo);
             if (jog == 0)
             {
                 MessageBox.Show("Hibas felhasznalonev vagy jelszo");
             }
             else
             {
				 felhNev = nev;
				 felhID = reader.getFelhIDByName(nev);
				 
                 Form1 form = new Form1(felhID, jog);
                 form.Show();
                 this.Hide();
             }

        }

        private void registerButton_Click(object sender, EventArgs e)
        {
            RegisterForm form = new RegisterForm();
            form.Show();
        }

        private void jelszoTextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                OkButton_Click(sender, e);
            }
        }
    }
}
